<?php
namespace app\user\model;
use think\Model;
use think\facade\Db;
use think\model\concern\SoftDelete;

class Notice extends Model
{
    use SoftDelete;
    protected $deleteTime = 'delete_time';
    protected $defaultSoftDelete = 0;
    protected $autoWriteTimestamp = true;
    protected $json = ['data'];
    protected $jsonAssoc = true;
    
    /**
     * 添加通知
     * @param datetime 通知时间
     * @param type $len 通知类型
     * @param data $len 通知关联数据
     * @param remark $name 通知备注内容
     * @return string
    */
    static function Add_Notice($datetime,$type,$data,$remark) {
        $result = self::create([
            'shop_id' => ShopId(),
            'user_id' => UserId(),
            'type'    => $type,
            'data'    => $data,
            'datetime'=> $datetime,
            'remark'  => $remark
        ]);
        return $result;
    }
    //保存开始时间
    public function setDateTimeAttr($value)
    {
        return strtotime($value);
    }
    //读取开始时间
    public function getDateTimeAttr($value)
    {
        return date('Y-m-d',$value);
    }
    
    
}